(function(){BX.namespace("BX.UI.SidePanel");if(BX.UI.SidePanel.Wrapper){return}function t(t){}t.prototype.init=function(t){this.container=BX(t.containerId);this.isCloseAfterSave=t.isCloseAfterSave||false;this.isReloadGridAfterSave=t.isReloadGridAfterSave||false;this.isReloadPageAfterSave=t.isReloadPageAfterSave||false;this.skipNotification=t.skipNotification||false;this.useLinkTargetsReplacing=t.useLinkTargetsReplacing||false;this.notification=t.notification||{};var e=BX.SidePanel.Instance.getPreviousSlider(BX.SidePanel.Instance.getSliderByWindow(window));this.parentWindow=e?e.getWindow():top;this.initEditableTitle(t);if(this.isReloadGridAfterSave){if(this.getParam("reloadGridAfterSave")){this.reloadGridOnParentPage()}this.setParam("reloadGridAfterSave",true)}if(this.isCloseAfterSave){if(this.getParam("closeAfterSave")){var i;if(this.notification.content&&top.BX&&!this.getParam("skipNotification")){i=function(){top.BX.loadExt("ui.notification").then(function(){top.BX.UI.Notification.Center.notify(this.notification)}.bind(this))}.bind(this)}else if(this.isReloadPageAfterSave){i=function(){this.parentWindow.location.reload()}.bind(this)}BX.SidePanel.Instance.close(false,i)}if(this.skipNotification){this.setParam("skipNotification",true)}this.setParam("closeAfterSave",true)}if(this.useLinkTargetsReplacing){this.initLinkTargetsReplacing()}};t.prototype.initEditableTitle=function(t){if(!t.title||!t.title.selector||!t.title.defaultTitle){return}var i=this.container.querySelector(t.title.selector);if(!i){return}var n=i.querySelector('input[type="text"]');if(!n){return}i.style.display="none";e.init({dataContainer:i,dataNode:n,defaultTitle:t.title.defaultTitle})};t.prototype.initLinkTargetsReplacing=function(){this.replaceLinkTargets();if(!window.MutationObserver){return}var t=new MutationObserver(this.domMutationHandler.bind(this));t.observe(this.container,{childList:true,subtree:true})};t.prototype.domMutationHandler=function(t){t.forEach(function(t){for(var e=0;e<t.addedNodes.length;++e){var i=t.addedNodes.item(e);if(!i){continue}this.replaceLinkTargets(i)}},this)};t.prototype.replaceLinkTargets=function(t){if(!t){t=document.body}var e=[];if(t.tagName==="A"){e=[t]}else if(t.nodeName!=="#text"){e=BX.convert.nodeListToArray(t.querySelectorAll("a"))}if(e.length===0){return}BX.convert.nodeListToArray(e).filter(function(t){return!t.target}).forEach(function(t){t.target="_top"})};t.prototype.setParam=function(t,e){var i=BX.SidePanel.Instance.getSliderByWindow(window);if(i){i.getData().set(t,e)}};t.prototype.getParam=function(t){var e=BX.SidePanel.Instance.getSliderByWindow(window);if(e){return e.getData().get(t)}return undefined};t.prototype.removeParam=function(t){var e=BX.SidePanel.Instance.getSliderByWindow(window);if(e){e.getData().delete(t)}};t.prototype.reloadGridOnParentPage=function(){var t=this.parentWindow;var e=BX.type.isString(this.isReloadGridAfterSave)?this.isReloadGridAfterSave:null;if(!t.BX.Main||!t.BX.Main.gridManager){return}if(e==="all"){t.BX.Main.gridManager.data.forEach(function(t){t.instance.reload()});return}if(!e&&t.BX.Main.gridManager.data){var i=t.BX.Main.gridManager.data;e=i.length>0?i[0].id:null}if(!e){return}var n=t.BX.Main.gridManager.getById(e);if(!n){return}n.instance.reload()};var e={isInit:false,init:function(t){this.dataNode=t.dataNode;this.titleNode=document.querySelector(".ui-side-panel-wrap-title-name");this.inputNode=document.querySelector(".ui-side-panel-wrap-title-input");this.buttonNode=document.querySelector(".ui-side-panel-wrap-title-edit-button");this.initialTitle=this.titleNode.textContent;this.defaultTitle=t.defaultTitle;BX.bind(this.dataNode,"bxchange",this.onDataNodeChange.bind(this));BX.bind(this.buttonNode,"click",this.startEdit.bind(this));BX.bind(this.inputNode,"keyup",this.onKeyUp.bind(this));BX.bind(this.inputNode,"blur",this.endEdit.bind(this));this.isInit=true;if(!t.disabled){this.enable()}if(!this.dataNode.value){this.dataNode.value=this.defaultTitle}},enable:function(t){t=t||false;if(!this.isInit){return}this.changeDisplay(this.buttonNode,!t);this.titleNode.textContent=!t?this.dataNode.value?this.dataNode.value:this.defaultTitle:this.initialTitle},disable:function(){this.enable(true)},onDataNodeChange:function(){this.titleNode.textContent=this.dataNode.value},onKeyUp:function(t){t=t||window.event;if(t.keyCode===10||t.keyCode===13){this.endEdit();t.preventDefault();return false}},getTitle:function(){var t=this.dataNode.value;if(!t){t=this.titleNode.textContent}return t},startEdit:function(){this.inputNode.value=this.getTitle();this.changeDisplay(this.titleNode,false);this.changeDisplay(this.buttonNode,false);this.changeDisplay(this.inputNode,true);this.inputNode.focus()},endEdit:function(){this.dataNode.value=this.inputNode.value;this.titleNode.textContent=this.inputNode.value;this.changeDisplay(this.inputNode,false);this.changeDisplay(this.buttonNode,true);this.changeDisplay(this.titleNode,true)},changeDisplay:function(t,e){return t.style.display=e?"":"none"}};BX.UI.SidePanel.Wrapper=new t})();
//# sourceMappingURL=template.map.js